home *** CD-ROM | disk | FTP | other *** search
- /* (C) Copyright 1991 Dave Fritsche (wb8zxu), All Rights Reserved.
- *
- * Redistribution and use in source and binary forms are permitted for
- * non-commercial use, provided that the above copyright notice and this
- * paragraph are duplicated in all such forms. THIS SOFTWARE IS PROVIDED
- * ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
- * WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE.
- */
- #include <stdio.h>
- #include <sys\stat.h>
- #include <string.h>
- #include "screen.h"
-
- mk_dir(dirpath)
- unsigned char dirpath[];
- {
- int rtn, m, n;
- unsigned char pathtmp[128], tmp[128], *ch;
- struct stat statbuf;
-
- strcpy(pathtmp, dirpath);
- ch = strtok(pathtmp, "\\");
- strcpy(tmp, ch);
-
- while (1)
- {
- if ( (ch = strtok(NULL, "\\")) == NULL )
- {
- if (debug)
- printf("***> mkdir %s -- already exists\n", tmp);
- return(0);
- }
- strcat(tmp, "\\");
- strcat(tmp, ch);
- if (stat(tmp, &statbuf) != 0)
- break;
- if ( (statbuf.st_mode & S_IFDIR) == 0 )
- {
- printf("\n(%s) is not a directory, can't proceed\n\n",
- tmp);
- exit(1);
- }
- }
-
- if (debug)
- printf("***> mkdir %s\n", tmp);
- else
- mkdir(tmp);
-
- while ( (ch = strtok(NULL, "\\")) != NULL )
- {
- strcat(tmp, "\\");
- strcat(tmp, ch);
- if (debug)
- printf("***> mkdir %s\n", tmp);
- else
- mkdir(tmp);
- }
- }
-